package com.katydid.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "note")
public class Note {
	
	@Id
	@Column(name = "note_id")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_gen")
    @SequenceGenerator(name="seq_gen", sequenceName="note_seq_gen", initialValue=1, allocationSize=12)
	private long id;

	@ManyToOne
	@Column(name = "tag_id")
	private Tag tag;

	private String title;
	
	@Lob
	private String content;

	private boolean important;

	@Column(name = "create_at")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdAt;

	@ElementCollection
	@CollectionTable(name = "note_url", joinColumns = @JoinColumn(name = "note_id"))
	@Column(name = "url")
	private List<String> urls = new ArrayList<String>();

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "note")
	private List<NoteImage> images;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Tag getTag() {
		return tag;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setTag(Tag tag) {
		this.tag = tag;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public boolean isImportant() {
		return important;
	}

	public void setImportant(boolean important) {
		this.important = important;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public List<String> getUrls() {
		return urls;
	}

	public void setUrls(List<String> urls) {
		this.urls = urls;
	}

	public List<NoteImage> getImages() {
		return images;
	}

	public void setImages(List<NoteImage> images) {
		this.images = images;
	}

}
